<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html>
<html>
<head>
<base href="${path}/">
<meta charset="UTF-8">
<title>非AJAX方式提交表单</title>
</head>
<body>
<center>
	<h1>用户登陆</h1><hr>
	<form id="myform" method="post">
		<table>
			<tr>
				<td>账号：</td>
				<td><input type="text" name="uname" id="uname"></td>
			</tr>
			<tr>
				<td>密码：</td>
				<td><input type="text" name="passwd" id="passwd"></td>
			</tr>
			<tr align="center">
				<td colspan="2">
					<input id="submitbtn" type="button" value="提交">
					<input type="reset" value="重置">
				</td>
			</tr>
		</table>
	</form>
</center>

<script src="js/jquery-1.7.min.js"></script>
<script>
$(function() {
	// 点击提交按钮
	$('#submitbtn').click(function() {
		var uname = $('#uname').val();
		var passwd = $('#passwd').val();
		if(uname=='' || passwd=='') {
			alert('账号或密码不能为空');
			return false;
		}
		
		var params = $('#myform').serialize(); 
		$.post('${path}/action/my/login2', params, function(data) {
			//alert(JSON.stringify(data));
			window.location.href = 'success.jsp';			
		}, 'json');
	});
})
</script>
</body>
</html>